/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package autonom.robot;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

/**
 *
 * @author Ragnar
 */
public class BeagleClient implements Runnable
{
    private DataOutputStream toServer;
    private DataInputStream fromServer;
    private Socket socket;
    
    public BeagleClient()
    {
        try
        {
            socket = new Socket("localhost", 4444);
        }
        catch(IOException e) {}
        Thread t = new Thread(this);
        t.start();
    }
    public void run()
    {
        while (true)
        {
            try
            {
                Thread.sleep(50);
                fromServer = new DataInputStream(socket.getInputStream());
                toServer = new DataOutputStream(socket.getOutputStream());
                toServer.writeDouble(5);
                double area = fromServer.readDouble();
                System.out.println("Area is: " + area);
            }
            catch(InterruptedException e) {}
            catch (IOException e) {}
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        new BeagleClient();
    }
    
}